package com.baosight.sczx.common.zm.cInterface.cs;

import java.util.HashMap;
import java.util.List;

import com.baosight.iplat4j.core.spring.SpringApplicationContext;
import com.baosight.iplat4j.dao.Dao;
import com.baosight.sczx.common.zm.cInterface.CmesConstants;
import com.baosight.sczx.zm.cs.domain.ZMCSSystemSettingCP;

/**
 * 系统设置-生产过程管理
 * <p>Title: SystemSettingCP.java</p>
 * <p>Description: </p>
 * <p>Copyright: Baosight Software LTD.co Copyright (c) 2002</p>
 * <p>Company: Baosight Software</p>
 * @author 严洪浩
 * @version 1.0
 * <pre>Histroy:
 *          2011-1-18 下午07:46:38  严洪浩  Create
 *</pre>
 */
public class SystemSettingCP {
	
	private static Dao dao = (Dao)SpringApplicationContext.getBean("dao");
	private static SystemSettingCP instance = new SystemSettingCP();
	private static ZMCSSystemSettingCP systemSetting;
	
	private SystemSettingCP(){
		initData();//当第一次使用的时候初始化
	}
	
	@SuppressWarnings("unchecked")
	private void initData(){
		List<ZMCSSystemSettingCP> _list = dao.query("ZMCSSystemSettingCP.query", new HashMap<String, String>());
		if(_list.size() < 1) {
			systemSetting = null;
		}
		else {
			systemSetting = _list.get(0);
		}
		CmesConstants.SYSTEMSETTING_CP = 0;
	}
	
	/**
	 * 计划开始日期
	 * <p>Function: getInventoryNo</p>
	 * <p>Description: </p>
	 * <p>return value:String</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-7-18上午02:34:01 严洪浩
	 * </p>
	 *
	 */
	public String getPlanBeginDate(){
		String _temp = new String("10-10");
		if(systemSetting != null) {
			_temp = systemSetting.getFdPlanBeginDate();
		}
		
		return _temp;
	}
	
	/**
	 * 自动获取数据开关 True开 False关， 默认为关闭
	 * <p>Function: getSystemModel</p>
	 * <p>Description: </p>
	 * <p>return value:String</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-1-18下午07:58:20 严洪浩
	 * </p>
	 *
	 */
	public boolean getAutoGetData(){
		String _temp = new String("0");//默认为 0关闭
		if(systemSetting != null) {
			_temp = systemSetting.getFdGetData();
			if(null == _temp || "".equals(_temp)) {
				_temp = new String("0");
			}
		}
		
		return Boolean.valueOf(_temp.toString());
	}
	
	/**
	 * 掘进煤是否统计 True统计，False不统计 默认为False
	 * <p>Function: getMiningType</p>
	 * <p>Description: </p>
	 * <p>return value:String</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-1-18下午08:17:55 严洪浩
	 * </p>
	 *
	 */
	public boolean getCoalCount(){
		String _temp = new String("0");//默认为 0不统计
		if(systemSetting != null) {
			_temp = systemSetting.getFdCoalCount();
			if(null == _temp || "".equals(_temp)) {
				_temp = new String("0");
			}
		}
		
		return Boolean.valueOf(_temp.toString());
	}
	
	/**
	 * 生产统计月起始日，默认为1日，为自然月
	 * <p>Function: getSystemName</p>
	 * <p>Description: </p>
	 * <p>return value:String</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-1-18下午08:18:36 严洪浩
	 * </p>
	 *
	 */
	public int getBeginDate(){
		String _temp = new String("1");//默认为 1日
		if(systemSetting != null) {
			_temp = systemSetting.getFdBeginDate();
			if(null == _temp || "".equals(_temp)) {
				_temp = new String("1");
			}
		}
		
		return Integer.parseInt(_temp.toString());
	}

		/**
	 * 统计月计算方式，默认是1——从起始日开始一个月算作本月，0——从起始日开始一个月算作下个月
	 * <p>Function: getReportMonthMode</p>
	 * <p>Description: </p>
	 * <p>return value:String</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2012-7-27上午06:02:40 张志芳
	 * </p>
	 *
	 */
	public String getReportMonthMode(){
		String _temp = new String("1");//默认为 1
		if(systemSetting != null) {
			_temp = systemSetting.getFdReportMonthMode();
		}
		
		return _temp;
	}
	/**
	 * 获得修改专业计划的起始日期 
	 * 默认为 0
	 * <p>Function: getModifyStartDate</p>
	 * <p>Description: </p>
	 * <p>return value:String</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2013-5-13下午01:20:27 王开兵
	 * </p>
	 *
	 */
	public String getModifyStartDate(){
		String _temp = new String("0");//默认为 0验收量
		if(systemSetting != null) {
			_temp = systemSetting.getFdModifyStartDate();
		}
		
		return _temp;
	}
	
	/**
	 * 获得修改专业计划的终止日期 
	 * 默认为 0
	 * <p>Function: getModifyEndDate</p>
	 * <p>Description: </p>
	 * <p>return value:String</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2013-5-13下午01:20:27 王开兵
	 * </p>
	 *
	 */
	public String getModifyEndDate(){
		String _temp = new String("0");//默认为 0验收量
		if(systemSetting != null) {
			_temp = systemSetting.getFdModifyEndDate();
		}
		
		return _temp;
	}
	/**
	 * 获得实际产量 0验收量 1调度量 2汇报量 3实时量
	 * 默认为 0验收量
	 * <p>Function: getVersion</p>
	 * <p>Description: </p>
	 * <p>return value:String</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-1-18下午08:20:27 严洪浩
	 * </p>
	 *
	 */
	public String getRealYield(){
		String _temp = new String("0");//默认为 0验收量
		if(systemSetting != null) {
			_temp = systemSetting.getFdRealYield();
		}
		
		return _temp;
	}
	
	/**
	 * 获取采煤量计算参数
	 * <p>Function: getMineParameter</p>
	 * <p>Description: </p>
	 * <p>return value:Double</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2012-3-23下午05:22:44 张志芳
	 * </p>
	 *
	 */
	public Double getMineParameter(){
		Double _temp = 0.7;//默认为0.7
		if(systemSetting != null) {
			_temp = systemSetting.getFdMineParameter();
		}
		
		return _temp;
	}
	
	/**
	 * 煤层容量
	 * <p>Function: getCoalDensity</p>
	 * <p>Description: </p>
	 * <p>return value:Double</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2012-4-13下午01:33:48 张志芳
	 * </p>
	 *
	 */
	public Double getCoalDensity(){
		Double _temp = 1.38;
		if(systemSetting != null) {
			_temp = systemSetting.getFdCoalDensity();
		}
		
		return _temp;
	}
	
	/**
	 * 矸石密度
	 * <p>Function: getGangueDensity</p>
	 * <p>Description: </p>
	 * <p>return value:Double</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2012-4-13下午01:34:22 张志芳
	 * </p>
	 *
	 */
	public Double getGangueDensity(){
		Double _temp = 2.6;
		if(systemSetting != null) {
			_temp = systemSetting.getFdGangueDensity();
		}
		
		return _temp;
	}
	
	/**
	 * 采煤验收总量计算公式    0-采高*回采面积*煤层容量1.38   
	 *                     1-（采高-矸石厚度）*回采面积*煤层容量1.38+矸石量
	 * <p>Function: getMineValidateFormula</p>
	 * <p>Description: </p>
	 * <p>return value:String</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2012-4-13下午01:40:26 张志芳
	 * </p>
	 *
	 */
	public String getMineValidateFormula(){
		String _temp = new String("0");//默认为 0
		if(systemSetting != null) {
			_temp = systemSetting.getFdMineValidateFormula();
		}
		
		return _temp;
	}
	
	/**
	 * 采煤验收测量方式   0-长方形  1-梯形
	 * <p>Function: getMeasuringMethod</p>
	 * <p>Description: </p>
	 * <p>return value:String</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2012-4-13下午01:39:23 张志芳
	 * </p>
	 *
	 */
	public String getMeasuringMethod(){
		String _temp = new String("0");//默认为 0
		if(systemSetting != null) {
			_temp = systemSetting.getFdMeasuringMethod();
		}
		
		return _temp;
	}
	
	/**
	 * 是否推算终止点
	 * <p>Function: getIsCalculateEnd</p>
	 * <p>Description: </p>
	 * <p>return value:boolean</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2012-4-13下午01:38:14 张志芳
	 * </p>
	 *
	 */
	public String getIsCalculateEnd(){
		String _temp = new String("1");//默认为1
		if(systemSetting != null) {
			_temp = systemSetting.getFdIsCalculateEnd();
		}	
		return _temp;
	}
	
	/**
	 * 矿井模型
	 * <p>Function: getMingModel</p>
	 * <p>Description: </p>
	 * <p>return value:boolean</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2013-6-26下午01:38:14 高强
	 * </p>
	 *
	 */
	public String getMingModel(){
		String _temp = new String("0");//默认为1
		if(systemSetting != null) {
			_temp = systemSetting.getFdMingModel();
		}	
		return _temp;
	}
	
	
	/**
	 * 安装调试天数
	 * <p>Function: getGangueDensity</p>
	 * <p>Description: </p>
	 * <p>return value:Double</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2013-9-10下午01:34:22梁琦
	 * </p>
	 *
	 */
	public Double getInstallationDays(){
		Double _temp =50.0;
		if(systemSetting != null) {
			_temp = systemSetting.getFdInstallationDays();
		}
		
		return _temp;
	}
	
	/**
	 * 同采面个数
	 * <p>Function: getGangueDensity</p>
	 * <p>Description: </p>
	 * <p>return value:Double</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2013-9-10下午01:34:22梁琦
	 * </p>
	 *
	 */
	public int getSametimeMineNum(){
		int _temp =2;
		if(systemSetting != null) {
			_temp = systemSetting.getFdSametimeMineNum().intValue();
		}
		
		return _temp;
	}
	
	/**
	 * 得到对象的唯一句柄
	 * <p>Function: getInstance</p>
	 * <p>Description: </p>
	 * <p>return value:SystemSettingCP</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-1-18下午07:50:20 严洪浩
	 * </p>
	 *
	 */
	public static SystemSettingCP getInstance(){
		if(CmesConstants.SYSTEMSETTING_CP == 1) {
			instance = new SystemSettingCP();
		}
		
		return instance;
	}
}
